package com.ea.eadp.nexus.test.pageDefinition;

import com.ea.eadp.nexus.test.common.PageOperation;
import com.ea.eadp.nexus.test.common.TestUtil;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.List;
import java.util.Random;

/**
 * User: woodywu
 */
public class Signup_PC extends BasePage {
    public static final String uri = baseUri + TestUtil.SignupPcConnectURI("smoke_client", null, "http://localhost/", null);
    public static final String redirectURI = "localhost";

    public Signup_PC(WebDriver driver) {
        super(driver, Signup_PC.class);
    }

    public void navigate() {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(uri);
        driver.navigate().to(uri);
    }

    public void navigate(String client_id, String locale, String redirectUri, String pc_machine_id) {
        driver.switchTo().window(this.operationWindowHandle);

        String signupUrl = baseUri + TestUtil.SignupPcConnectURI(client_id, locale, redirectUri, pc_machine_id);
        log.info(signupUrl);
        driver.get(signupUrl);
    }

    public void navigate(String uri) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(uri);
        driver.get(uri);
    }

    public void setDobMonth(String month) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(month);
        String cssSelector = "#clientreg_dobmonth";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, month);
    }

    public void setDobDay(String day) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(day);
        String cssSelector = "#clientreg_dobday";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, day);
    }

    public void setDobYear(String year) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(year);
        String cssSelector = "#clientreg_dobyear";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, year);
    }

    public void setRegisterCountry(String country) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(country);
        String cssSelector = "#clientreg_country";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, country);
    }

    /**
     * click "Next" button on pre-registration page, redirect to 's1' page
     */
    public void clickToSignupBasicS1() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//a[@id='continue-btn']/span/span")).click();
        identifierId = "originId";
        PageOperation.WebDriverWait(driver, identifierId);
        if (!TestUtil.getCurrentUrl(driver).contains("s1")) {
            throw new Exception("validate goes to 's1' page.");
        }
    }


    /**
     * click "Continue" button on underage pre-registration page, redirect to 's1' page
     */
    public void clickToUnderageSignupBasicS1() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//a[@id='continue-btn']/span/span")).click();
        identifierId = "panel-dob-warning";
        PageOperation.WebDriverWait(driver, identifierId);
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='panel-dob-warning']/div[3]/a[2]/span/span")).click();
        identifierId = "originId";
        PageOperation.WebDriverWait(driver, identifierId);
        if (!TestUtil.getCurrentUrl(driver).contains("s1")) {
            throw new Exception("validate goes to 's1' page.");
        }
    }

    /**
     * click "Next" button on pre-registration page, redirect to 's1' page
     */
    public boolean canClickToSignupBasicS2() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        String state = driver.findElement(By.xpath("//a[@id='submit-btn']")).getAttribute("class");
        return state.endsWith("ready");
    }

    /**
     * The 'Next' button on pre-registration page, click this button will show errors on this page
     */
    public void clickNextOnPreRegrationPage(String cssSelector) {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='panel-splash']/div[3]/a[2]/span/span")).click();
        PageOperation.WebDriverWaitByXpath(driver, cssSelector);

    }

    public void setOriginID(String originID) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(originID);
        PageOperation.SendKeyToElement(driver, "originId", originID);
    }

    /**
     * get attribute 'MaxLength' for Origin ID, confirm if it is '16'
     */
    public String getMaxLengthForOriginID() {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.id("originId")).getAttribute("maxlength");
    }

    public void setSignupEmail(String email) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(email);
        PageOperation.SendKeyToElement(driver, "email", email);
    }

    public void setParentEmail(String email) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(email);
        PageOperation.SendKeyToElement(driver, "parentEmail", email);
    }

    public void setSignupPassword(String password) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(password);
        PageOperation.SendKeyToElement(driver, "password", password);
    }

    public void setConfirmPassword(String confirmPassword) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(confirmPassword);
        PageOperation.SendKeyToElement(driver, "confirmPassword", confirmPassword);
    }

    public void setSecurityQuestion(String question) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(question);
        String cssSelector = "#clientreg_securityqa";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, question);
    }

    public void setSecurityAnswer(String answer) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(answer);
        PageOperation.SendKeyToElement(driver, "securityAnswer", answer);
    }

    public void setVisibility(String visibility) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(visibility);
        String cssSelector = "#clientreg_friend_visibility";
        PageOperation.SelectCssDropDownItem(driver, cssSelector, visibility);
    }

    public void checkboxSearchByEmail(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.SelectCheckbox(driver, "emailVisibility", "label-emailVisibility", check);
    }

    public void checkboxSearchByXboxId(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.SelectCheckbox(driver, "xboxVisibility", "label-xboxVisibility", check);
    }

    public void checkboxSearchByPSNId(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.SelectCheckbox(driver, "psnVisibility", "label-psnVisibility", check);
    }

    public void setCaptcha(String value) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(value);

        PageOperation.SendKeyToElement(driver, "recaptcha_response_field", value);
    }

    public void checkboxContactMe(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.SelectCheckbox(driver, "contactMe", "label-contactMe", check);
    }

    public void checkboxShareInfo(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.SelectCheckbox(driver, "shareInfo", "label-shareInfo", check);
    }

    public void checkboxReadAccept(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        if (check && !driver.findElement(By.id("readAccept")).isSelected()) {
            driver.findElement(By.xpath("//li[@id='read-accept-container']/div/div/span")).click();
        } else if (!check && driver.findElement(By.id("readAccept")).isSelected()) {
            driver.findElement(By.xpath("//li[@id='read-accept-container']/div/div/span")).click();
        }
    }

    public void checkboxReadAcceptParent(boolean check) {
        driver.switchTo().window(this.operationWindowHandle);
        if (check && !driver.findElement(By.id("readAccept")).isSelected()) {
            driver.findElement(By.xpath("//li[@id='read-accept-container']/div/div/span")).click();
        } else if (!check && driver.findElement(By.id("readAccept")).isSelected()) {
            driver.findElement(By.xpath("//li[@id='read-accept-container']/div/div/span")).click();
        }
    }

    /**
     * 'Cancel' button on register Basic Info page, click this button then redirect to login page
     */
    public void clickCancelToCancelRegister() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        JavascriptExecutor jse = (JavascriptExecutor)driver;
        jse.executeScript("$('" + "div.panel-action-area > a.btn-cancel > span > span:visible" + "').click();");
        PageOperation.WebDriverWaitByCssSelector(driver, "#login-container");
        if (!TestUtil.getCurrentUrl(driver).contains("login")) {
            throw new Exception("click 'Cancel' should redirect to login page");
        }
    }

    /**
     * click 'Next' button on s1 page, then redirect to 's2' page
     */
    public void clickToSignupBasicS2() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        WebElement element = driver.findElement(By.cssSelector(
                "#panel-basic-information > div.panel-action-area > #submit-btn > span > span"));
        Actions actions = new Actions(driver);
        actions.moveToElement(element).click().perform();
        identifierId = "firstName";
        PageOperation.WebDriverWait(driver, identifierId);
        if (!TestUtil.getCurrentUrl(driver).contains("s2")) {
            throw new Exception("validate goes to 's2' page.");
        }
    }

    public void clickToSignupBasicS2RU()throws Exception{
        driver.switchTo().window(this.operationWindowHandle);
        WebElement element = driver.findElement(By.cssSelector(
                "#panel-basic-information > div.panel-action-area > #submit-btn > span > span"));
        Actions actions = new Actions(driver);
        actions.moveToElement(element).click().perform();
    }

    public void setFirstName(String firstName) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(firstName);
        PageOperation.SendKeyToElement(driver, "firstName", firstName);
    }

    public void setLastName(String lastName) {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(lastName);
        PageOperation.SendKeyToElement(driver, "lastName", lastName);
    }

    /**
     * click 'sign up' button on create profile page, then redirect to 's3' page
     */
    public void clickToSignupBasicS3() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='panel-profile-settings']/div[4]/a[2]/span/span")).click();
        identifierId = "panel-profile-confirmation";
        PageOperation.WebDriverWait(driver, identifierId);
        if (!TestUtil.getCurrentUrl(driver).contains("s3")) {
            throw new Exception("validate goes to 's3' page.");
        }
    }

    /**
     * click 'close' button on 's3' page, then redirect to 'about me' page
     */
    public void clickToSignupComplete() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='panel-profile-settings']/div[4]/a[2]/span/span")).click();
        //PageOperation.WebDriverWaitByXpath(driver, "//div[@id='mod-navigation']");
        Thread.sleep(2000);
        if (!TestUtil.getCurrentUrl(driver).contains(redirectURI)) {
            throw new Exception("validate goes to redirect uri.");
        }
        //Assert.assertEquals(TestUtil.getCurrentUrl(driver).contains("about/me?fid="), true, "validate goes to 'about me' page.");
    }

    /**
     * click 'Next' button during sign up underage page, will redirect to success page
     */
    public void clickToSignupLimitAccountComplete() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.cssSelector(
                "#panel-basic-information > div.panel-action-area > #submit-btn > span > span")).click();
        PageOperation.WebDriverWait(driver, "panel-profile-confirmation");
        if (!TestUtil.getCurrentUrl(driver).contains("create")) {
            throw new Exception("validate goes to 'create' page");
        }
    }

    /**
     * get the error messages for the element by xpath
     */
    public String getErrorMessageByXPath(String xpath) {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.xpath(xpath)).getText();
    }

    /**
     * the control will become 'field-error' when it has error, get it by xpath
     */
    public String getErrorClassByXPath(String xpath) {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.xpath(xpath)).getAttribute("class").toString();
    }

    /**
     * send tab to move the cursor
     */
    public void sendTab(String elementID) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info("[Tab]");
        driver.findElement(By.id(elementID)).sendKeys("\t");
        Thread.sleep(2000);
    }

    /**
     * 'skip' button on create profile page, click this button skip create profile, and go to 'about me' page directly
     */
    public void clickSkip() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='panel-profile-settings']/div[4]/a[2]/span/span")).click();
        Thread.sleep(2000);
        if (!TestUtil.getCurrentUrl(driver).contains(redirectURI)) {
            throw new Exception("validate goes to redirect uri.");
        }
        //PageOperation.WebDriverWaitByXpath(driver, "//div[@id='mod-navigation']");
        //Assert.assertEquals(TestUtil.getCurrentUrl(driver).contains("about/me?fid="), true, "validate goes to 'about me' page.");
    }

    /**
     * get the status for 'sign up' button on the create profile page
     */
    public String getStatusForSignup() {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.xpath("//div[@id='panel-profile-settings']/div[4]/a[2]")).getAttribute("class").toString();
    }

    /**
     * get the status for 'Next' button during sign up
     */
    public String getStatusForNext() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.xpath("//div[@id='panel-basic-information']/div[3]/a[2]")).getAttribute("class").toString();
    }

    public void clickChooseAvatar() {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@id='profile-settings-avatar-container']/a/span/span")).click();
        PageOperation.WebDriverWait(driver, "a-uploader");
    }

    public void clickUploadImgTab() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.id("a-uploader")).click();
        Thread.sleep(2000);
        //PageOperation.WebDriverWait(driver, "fileupload");
    }

    public void setImage(String file, boolean larger) throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        log.info(file);
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("document.getElementById('fileupload').style.margin=0");
        driver.findElement(By.id("fileupload")).sendKeys(file);
        if (larger) {
            PageOperation.WebDriverWait(driver, "error-message-upload-text");
        } else {
            WebDriverWait wait = new WebDriverWait(driver, 30, 1000);
            wait.until(new ExpectedCondition<Boolean>() {
                public Boolean apply(WebDriver driver) {
                    return !driver.findElement(By.id("element-avatar-preview")).getAttribute("src").contains("/p/images/nouser.jpg");
                }
            });
            //PageOperation.WebDriverWait(driver, "element-avatar-preview");
        }
    }

    public void clickSaveAvatar() {
        driver.switchTo().window(this.operationWindowHandle);
        PageOperation.WebDriverWaitByCssSelector(driver, "#button-next-crop > span > span");
        driver.findElement(By.cssSelector("#button-next-crop > span > span")).click();
    }

    public void clickToSelectAvatarList() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        List<WebElement> elementList
                = driver.findElement(By.xpath("//div[@id='gallery']/div[1]/ul[1]")).findElements(By.tagName("li"));
        Random random = new Random();
        int index = random.nextInt(elementList.size());
        PageOperation.WebDriverWaitByXpath(driver, "//div[@id='gallery']/div[1]/ul[1]");
        elementList.get(index).click();
        Thread.sleep(3000);
    }

    public void clickToSelectAvatar() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        List<WebElement> elementList
                = driver.findElement(By.xpath("//div[@id='avatar-pics']")).findElements(By.tagName("a"));
        Random random = new Random();
        int index = random.nextInt(elementList.size());
        elementList.get(index).findElement(By.tagName("img")).click();
        PageOperation.WebDriverWaitByCssSelector(driver, "#button-next-gallery > span > span");
        driver.findElement(By.cssSelector("#button-next-gallery > span > span")).click();
    }

    public String getVisibility() {
        return getElementStringByXPath("//div[@id='clientreg_friend_visibility']/div[1]/span");
    }

    public String getH1OnPreRegisterPage() {
        return getElementStringByXPath("//div[@id='panel-profile']/h2");
    }

    public String getDOBLabel() {
        return getElementStringByXPath("//li[@id='dob-container']/div/label");
    }

    public String getCountryLabel() {
        return getElementStringByXPath("//li[@id='country-container']/div/label");
    }

    public String getContinueButtonStringOnPreRegisterPage() {
        return getElementStringByXPath("//a[@id='continue-btn']/span/span");
    }

    public String getCancelButtonStringOnPreRegisterPage() {
        return getElementStringByXPath("//div[@id='panel-splash']/div[3]/a[1]/span/span");
    }

    public String getSelectedMonth() {
        return getElementStringByXPath("//div[@id='clientreg_dobmonth']/div[1]/span");
    }

    public String getSelectedDay() {
        return getElementStringByXPath("//div[@id='clientreg_dobday']/div[1]/span");
    }

    public String getSelectedYear() {
        return getElementStringByXPath("//div[@id='clientreg_dobyear']/div[1]/span");
    }

    public String getSelectedCountry() {
        return getElementStringByXPath("//div[@id='clientreg_country']/div[1]/span");
    }

    public String getH1() {
        return getElementStringByXPath("//div[@id='panel-profile']/h1");
    }

    public String getH1OnCreateProfilePage() {
        return getElementStringByXPath("//div[@id='panel-profile-settings']/div[2]/div/h1");
    }

    public String getH2() {
        return getElementStringByXPath("//div[@id='panel-profile']/h2");
    }

    public String getOriginIDLabel() {
        return getElementStringByXPath("//li[@id='origin-id-container']/div/label");
    }

    public String getOriginIDTip() throws Exception {
        driver.switchTo().window(this.operationWindowHandle);
        //driver.findElement(By.xpath("//li[@id='origin-id-container']/div/label/span/a")).click();
        driver.findElement(By.cssSelector("a.origin-ux-tooltip-icon")).click();
        return getElementStringByXPath("//li[@id='origin-id-container']/div/label/span/span");
    }

    public String getEmailLabel() {
        return getElementStringByXPath("//li[@id='email-container']/div/label");
    }

    public String getPasswordLabel() {
        return getElementStringByXPath("//li[@id='password-container']/div/label");
    }

    public String getPasswordTip() {
        return getElementStringByXPath("//li[@id='password-container']/p");
    }

    public String getParentEmailLabel() {
        return getElementStringByXPath("//li[@id='parent-email-container']/div/label");
    }

    public String getConfirmPwdLabel() {
        return getElementStringByXPath("//li[@id='confirm-password-container']/div/label");
    }

    public String getPrivacyLabel() {
        return getElementStringByXPath("//div[@id='panel-privacy-settings']/h2");
    }

    public String getProfileTip() {
        return getElementStringByXPath("//div[@id='panel-privacy-settings']/p");
    }

    public String getVisibilityLabel() {
        return getElementStringByXPath("//li[@id='friend-visibility-container']/div/label");
    }

    public String getSearchabilityLabel() {
        return getElementStringByXPath("//li[@id='searchability-of-user-label-container']/label");
    }

    public String getEmailVisibility() {
        return getElementStringByXPath("//li[@id='email-visibility-container']/div/div/label");
    }

    public String getXBoxVisibility() {
        return getElementStringByXPath("//li[@id='xbox-visibility-container']/div/div/label");
    }

    public String getPSNVisibility() {
        return getElementStringByXPath("//li[@id='psn-visibility-container']/div/div/label");
    }

    public String getSecuirtyPreferences() {
        return getElementStringByXPath("//div[@id='panel-security-preferences']/h2");
    }

    public String getCaptchaLabel() {
        return getElementStringByXPath("//li[@id='captcha-container']/div/label");
    }

    public String getContactMeLabel() {
        return getElementStringByXPath("//label[@id='label-contactMe']");
    }

    public String getShareInfoLabel() {
        return getElementStringByXPath("//label[@id='label-shareInfo']");
    }

    public String getReadAcceptLabel() {
        return getElementStringByXPath("//label[@id='label-readAccept']");
    }

    public String getCreateAccountBtnString() {
        return getElementStringByXPath("//a[@id='submit-btn']/span/span");
    }

    public String getCancelBtnString() {
        return getElementStringByXPath("//div[@id='panel-basic-information']/div[3]/a[1]/span/span");
    }

    public String getErrorByElementID(String elementID) {
        String actualError = getErrorClassByXPath("//li[@id='" + elementID + "']/div");
        if (actualError.contains("field-error")) {
            String actualErrorMessage =
                    getErrorMessageByXPath("//li[@id='" + elementID + "']/div[1]/span[3]");
            return actualErrorMessage;
        }
        return null;
    }
    public String getErrorForFirstName() {
        return getErrorByElementID("name-first-container");
    }
    public String getErrorForLastName() {
        return getErrorByElementID("name-last-container");
    }
    public String getErrorForOriginID() {
        return getErrorByElementID("origin-id-container");
    }

    public String getErrorForEmail() {
        return getErrorByElementID("email-container");
    }

    public String getErrorForParentEmail() {
        return getErrorByElementID("parent-email-container");
    }

    public String getErrorForPassword() {
        return getErrorByElementID("password-container");
    }

    public String getErrorForConfirmPassword() {
        return getErrorByElementID("confirm-password-container");
    }

    public String getErrorForSecurityAnswer() {
        return getErrorByElementID("secanswer-container");
    }

    public String getUploadError() {
        return getErrorMessageByXPath("//div[@id='error-message-upload-text']");
    }


    public String getMaxLength(String elementID) {
        driver.switchTo().window(this.operationWindowHandle);
        return driver.findElement(By.id(elementID)).getAttribute("maxlength");
    }

    public String getSecQuestionLabel() {
        return getElementStringByXPath("//li[@id='secquestion-container']/div/label");
    }

    public String getSecAnswerLabel() {
        return getElementStringByXPath("//li[@id='secanswer-container']/div/label");
    }

    public String getProfileSetting() {
        return getElementStringByXPath("//div[@id='panel-profile-settings']/div[2]/div/p");
    }

    public String getFirstNameLabel() {
        return getElementStringByXPath("//li[@id='name-first-container']/div/label");
    }

    public String getLastNameLabel() {
        return getElementStringByXPath("//li[@id='name-last-container']/div/label");
    }

    public String getAvatarButtonString() {
        return getElementStringByXPath("//div[@id='profile-settings-avatar-container']/a/span/span");
    }

    public String getContinueButtonString() {
        return getElementStringByXPath("//div[@id='panel-profile-settings']/div[4]/a[2]/span/span");
    }

    public String getSkipButtonString() {
        return getElementStringByXPath("//div[@id='panel-profile-settings']/div[4]/a[1]/span/span");
    }

    public String getH2OnAvatar() {
        return getElementStringByXPath("//div[@id='panel-avatar-settings']/div[1]/div[1]/h2");
    }

    public String getAvatarGalleryTab() {
        return getElementStringByXPath("//a[@id='a-gallery']");
    }

    public String getSaveButton() {
        return getElementStringByXPath("//a[@id='button-next-gallery']/span/span");
    }

    public String getCancelButtonOnAvatarWindow() {
        return getElementStringByXPath("//div[@id='panel-avatar-settings']/div[2]/a[1]/span/span");
    }

    public String getUploadAvatarTab() {
        return getElementStringByXPath("//a[@id='a-uploader']");
    }

    public String getFileNotice() {
        return getElementStringByXPath("//div[@id='uploader']/div[3]/span");
    }

    public String getProfileConfirmCopy() {
        return getElementStringByXPath("//div[@id='panel-profile-confirmation']/div[2]/div/p[1]");
    }

    public String getProfileConfirmFooterCopy() {
        return getElementStringByXPath("//div[@id='panel-profile-confirmation']/div[2]/div/p[2]");
    }

    public void scrollToPreferences() {
        org.openqa.selenium.WebElement element = driver.findElement(By.xpath("//*[@id=\"panel-security-preferences\"]"));
        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
    }
    /*
    public String getParentEmailTip() {
        JavascriptExecutor jse = (JavascriptExecutor) driver;

    } */
    public String getContactUsTooltipString(){
        org.openqa.selenium.WebElement webElement = driver.findElement(By.xpath("//span[@id='contact_us']")) ;
        return webElement.getAttribute("title");
    }
    public String getAccountInfoTooltipString(){
        org.openqa.selenium.WebElement webElement = driver.findElement(By.xpath("//span[@id='account_info']")) ;
        return webElement.getAttribute("title");
    }
    public String getDetailsTooltipString(){
        org.openqa.selenium.WebElement webElement = driver.findElement(By.xpath("//span[@id='details']")) ;
        return webElement.getAttribute("title");
    }
    public String getOriginUxTooltipString(){
        org.openqa.selenium.WebElement webElement = driver.findElement(By.xpath("//li[@id='share-info-container']/div[1]/div/div/div/div[2]/span")) ;
        return webElement.getAttribute("innerHTML");
    }
}
